<template>
	<view class="order">
		<uni-nav-bar left-icon="arrowleft" right-icon="search" title="断货情况报表" @clickLeft="back" @clickRight="find" :fixed="true" class="top" status-bar></uni-nav-bar>
		<view class="statistics">
			<view class="ul">
				<view class="li">
					<view>{{detail.todayAchi||'0.00'}}</view>
					今日断货    
				</view>
				<view class="li">
					<view>{{detail.totalAchi||'0.00'}}</view>
					 累计断货
				</view>
			</view>
		</view>
		<view class="list">
			<view class="li" v-for="(item,index) in list">
				<view class="shop">
					<image :src="imgCDNUrl + item.productImg" mode="aspectFill"></image>
					<view class="msg">
						<view class="order black">订单号：{{item.orderSn}}</view>
						<view class="time gray ">下单时间：{{item.createdTime}}</view>
						<view class="sizr gray ">颜色：{{item.productSku[0]}}</view>
						<view class="sizr gray ">尺码：{{item.productSku[1]}}</view>
					</view>
				</view>
				<view class="genre">
					<text class="orderfrom">需退款人：{{item.refunder}}</text>
					<view class="msg">
						共1件
						<view class="price">
							合计：
							<text>¥{{item.orderPrice}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="total">合计：订单总额 {{money||'0.00'}}</view>
		</view>
		<view class="pagination">
			<view class="left" :class="{ forbid: paging.page == 1 }" @click="prev">
				<uni-icons type="arrowleft" size="20" color="#fff" class="icons" />
				上一页
			</view>
			<view class="center">{{ paging.page }}/{{ paging.total }}</view>
			<view class="right" :class="{ forbid: paging.page == paging.total }" @click="next">
				下一页
				<uni-icons type="arrowright" size="20" color="#fff" class="icons" />
			</view>
		</view>
		<view class="go-top" v-show="is_go_top" @click="backTop"><image src="/static/img/go_top.png" /></view>
	</view>
</template>

<script>
import { uniNavBar, uniIcons } from '@dcloudio/uni-ui';
import salesreturn from '../../../servers/agent/statement/salesreturn.js';
export default {
	components: { uniNavBar, uniIcons },
	data() {
		return {
			active: 0,
			dataList: [1],
			paging: {
				page: 1,
				total: 100
			},
			is_go_top: false,
			detail:[],
			list:[],
			money:0
		};
	},
	onPageScroll: function(e) {
		//nvue暂不支持滚动监听，可用bindingx代替
		if (e.scrollTop > 200) {
			this.is_go_top = true;
		} else {
			this.is_go_top = false;
		}
	},
	mounted() {
		this.getoutOfStockReport()
		this.getstatistics()
	},
	methods: {
		getstatistics(){
			salesreturn.outstatistics().then(res => {
				this.detail=res.data
			})
		},
		getoutOfStockReport(){
			var da = {
				currentPage: this.paging.page,
				pageSize: 10
			}
			salesreturn.outOfStockReport(da).then(res => {
					this.list = res.data.records.map(v=>{
						var productSku = []
						var sku = [];
						if (v.productSkuDesp) {
							sku = v.productSkuDesp.split(",");
							sku.map(v1=>{
								productSku.push(v1.split(":")[1]) 
							})
						}
						v.productSku=productSku
						this.money+=v.orderPrice
						return v
					})
					this.paging.total = res.data.pages||1
					// this.paging.page = res.data.pages||1
				})
				.catch(err => {
					console.log(new Error('请检查网络后重试'));
				});
		},
		back() {
			uni.navigateBack({
				delta: 1
			});
		},
		cut(e) {
			this.active = e;
		},
		find() {
			uni.navigateTo({
				url: '../order/orderfind'
			});
		},
		next() {
			if (this.paging.page < this.paging.total) {
				this.paging.page += 1;
			}
		},
		prev() {
			if (this.paging.page > 1) {
				this.paging.page -= 1;
			}
		},
		// 计算距离顶部的高度，均分10等分，
		backTop() {
			uni.pageScrollTo({
				scrollTop: 0,
				duration: 200
			});
		}
	}
};
</script>

<style lang="less" scoped>
page {
	background: #ffffff;
}
.order {
	.statistics {
		margin: 37rpx 20rpx 0;
		background: #ffffff;
		border-radius: 10rpx;
		box-shadow: 5rpx 0px 20rpx #c5c5c5;
		.ul {
			padding: 30rpx 0;
			line-height: 60rpx;
			display: flex;
			flex-direction: row;
			text-align: center;
			font-size: 26rpx;
			border-bottom: 1px solid #e1e1e1;
			.li {
				width: 50%;
				font-size: 26rpx;
				view {
					font-size: 40rpx;
					font-weight: 900;
					color: #f70225;
				}
			}
			.li:nth-child(1) {
				border-right: 1px solid #E1E1E1;
			}
		}
	}
	.list {
		// border-top: 26rpx solid #f6f6f6;
		padding: 0 20rpx;
		.li {
			padding: 50rpx 0;
			border-bottom: 1px solid #e1e1e1;
			.shop {
				position: relative;
				display: flex;
				flex-direction: row;
				image {
					width: 230rpx;
					height: 230rpx;
					border-radius: 10rpx;
				}
				.msg {
					width: 431rpx;
					margin-left: 37rpx;
					line-height: 46rpx;
					.order {
						font-size: 28rpx;
					}
					.type {
						font-size: 26rpx;
					}
					.gray {
						color: #999999;
						font-size: 26rpx;
						line-height: 42rpx;
					}
				}
			}
			.genre {
				color: #bd3c8c;
				padding-top: 57rpx;
				display: flex;
				flex-direction: row;
				font-size: 26rpx;
				.orderfrom {
					width: 50%;
					color: #bd3c8c;
				}
				.msg {
					color: #999999;
					text-align: right;
					width: 50%;
					.price {
						display: inline-block;
						color: #333333;
						margin-left: 29rpx;
						text {
							font-size: 30rpx;
							color: #333333;
						}
					}
				}
			}
		}
		.li:nth-last-child(1) {
			border-bottom: none;
		}
		.total {
			text-align: center;
			color: #f70225;
			font-size: 30rpx;
			line-height: 140rpx;
		}
	}
}
</style>
